Force usage of gbfile-API.
authoroliskoli <oliskoli>
Sun, 13 Aug 2006 17:23:26 +0000 (17:23 +0000)
committeroliskoli <oliskoli>
Sun, 13 Aug 2006 17:23:26 +0000 (17:23 +0000)
compegps.c
cst.c
garmin_txt.c
stmwpp.c

index 92f100d75cf3d540b5a06b7cf851c055b4d9d054..1de2ef150d95796df713f525c8607f30bb166608 100644 (file)
@@ -25,6 +25,7 @@
                10/25/2005: becomes a writer too
                10/26/2005: received documention from CompeGPS team
                            added fatals for "G" and "U" if not WGS84 and lat/lon
+               08/13/2006: switch to gbfile api
 */
 
 /*  
@@ -69,8 +70,7 @@
 
 #define SHORT_NAME_LENGTH 16
 
-static FILE *fin, *fout;
-static char *fin_name, *fout_name;
+static gbfile *fin, *fout;
 static int target_index, curr_index;
 static int track_info_flag;
 static short_handle sh;
@@ -317,28 +317,25 @@ parse_rte_info(const char *buff, route_head *route)       /* "R" */
 static void
 compegps_rd_init(const char *fname)
 {
-       fin_name = (char *)fname;
-       fin = xfopen(fname, "rb", MYNAME);
+       fin = gbfopen(fname, "rb", MYNAME);
 }
 
 static void
 compegps_rd_deinit(void)
 {
-       fclose(fin);
+       gbfclose(fin);
 }
 
 static void
 compegps_data_read(void)
 {
-       textfile_t *tin;
        char *buff;
        int line = 0;
        waypoint *wpt = NULL;
        route_head *route = NULL;
        route_head *track = NULL;
        
-       tin = textfile_init(fin);
-       while ((buff = textfile_read(tin)))
+       while ((buff = gbfgetstr(fin)))
        {
                char *cin = buff;
                char *ctail, *cx;
@@ -408,7 +405,6 @@ compegps_data_read(void)
                                break;
                }
        }
-       textfile_done(tin);
 }
 
 /* ----------------------------------------------------------- */
@@ -422,16 +418,16 @@ write_waypt_cb(const waypoint *wpt)
        
        name = (snlen > 0) ? mkshort_from_wpt(sh, wpt) : csv_stringclean(wpt->shortname, " ");
        
-       fprintf(fout, "W  %s A ", name);
-       fprintf(fout, "%.10f%c%c ",
+       gbfprintf(fout, "W  %s A ", name);
+       gbfprintf(fout, "%.10f%c%c ",
                fabs(wpt->latitude), 0xBA, (wpt->latitude >= 0) ? 'N' : 'S');
-       fprintf(fout, "%.10f%c%c ",
+       gbfprintf(fout, "%.10f%c%c ",
                fabs(wpt->longitude), 0xBA, (wpt->longitude >= 0) ? 'E' : 'W');
-       fprintf(fout, "27-MAR-62 00:00:00 %.6f", 
+       gbfprintf(fout, "27-MAR-62 00:00:00 %.6f", 
                (wpt->altitude != unknown_alt) ? wpt->altitude : 0.0);
        if (wpt->description != NULL)
-               fprintf(fout, " %s", wpt->description);
-       fprintf(fout, "\n");
+               gbfprintf(fout, " %s", wpt->description);
+       gbfprintf(fout, "\n");
        
        if ((wpt->icon_descr != NULL) || (wpt->proximity > 0.0) || \
            (option_icon != NULL))
@@ -440,7 +436,7 @@ write_waypt_cb(const waypoint *wpt)
                
                if (wpt->icon_descr != NULL) icon = (char *) wpt->icon_descr;
                        
-               fprintf(fout, "w  %s,0,0.0,16777215,255,1,7,,%.1f\n",
+               gbfprintf(fout, "w  %s,0,0.0,16777215,255,1,7,,%.1f\n",
                        (icon != NULL) ? icon : "Waypoint",
                        (wpt->proximity > 0.0f) ? wpt->proximity : 0.0);
        }
@@ -460,7 +456,7 @@ write_route_hdr_cb(const route_head *rte)
                name = csv_stringclean(name, ",");
        else
                name = xstrdup(" ");
-       fprintf(fout, "R  16711680,%s,1,-1\n", name);
+       gbfprintf(fout, "R  16711680,%s,1,-1\n", name);
        xfree(name);
 }
 
@@ -500,17 +496,17 @@ write_trkpt_cb(const waypoint *wpt)
                strupper(buff);
        }
        
-       fprintf(fout, "T  A %.10f%c%c %.10f%c%c ",
+       gbfprintf(fout, "T  A %.10f%c%c %.10f%c%c ",
                fabs(wpt->latitude), 0xBA, (wpt->latitude >= 0) ? 'N' : 'S',
                fabs(wpt->longitude), 0xBA, (wpt->longitude >= 0) ? 'E' : 'W');
-       fprintf(fout, "%s s %.1f %.1f %.1f %.1f %d ",
+       gbfprintf(fout, "%s s %.1f %.1f %.1f %.1f %d ",
                buff,
                wpt->altitude,
                0.0,
                0.0,
                0.0,
                0);
-       fprintf(fout, "%.1f %.1f %.1f %.1f %.1f\n",
+       gbfprintf(fout, "%.1f %.1f %.1f %.1f %.1f\n",
                -1000.0,
                -1.0,
                -1.0,
@@ -524,7 +520,7 @@ write_trkpt_cb(const waypoint *wpt)
                        char *name;
                        
                        name = csv_stringclean(curr_track->rte_name, "|");
-                       fprintf(fout, "t 4294967295|%s|-1|-1\n", name);
+                       gbfprintf(fout, "t 4294967295|%s|-1|-1\n", name);
                        xfree(name);
                }
        }
@@ -535,9 +531,9 @@ write_track(void)
 {
        curr_index = 0;
        
-//     fprintf(fout, "L  +02:00:00\n");
+//     gbfprintf(fout, "L  +02:00:00\n");
        track_disp_all(write_track_hdr_cb, NULL, write_trkpt_cb);
-       fprintf(fout, "F  1234\n");
+       gbfprintf(fout, "F  1234\n");
 }
 
 static void
@@ -551,8 +547,7 @@ write_waypoints(void)
 static void
 compegps_wr_init(const char *fname)
 {
-       fout_name = (char *)fname;
-       fout = xfopen(fname, "w", MYNAME);
+       fout = gbfopen(fname, "w", MYNAME);
        sh = mkshort_new_handle();
 }
 
@@ -560,7 +555,7 @@ static void
 compegps_wr_deinit(void)
 {
        mkshort_del_handle(&sh);
-       fclose(fout);
+       gbfclose(fout);
 }
 
 static void
@@ -568,8 +563,8 @@ compegps_data_write(void)
 {
        /* because of different file extensions we can only write one GPS data type at time */
        
-       fprintf(fout, "G  WGS 84\n");
-       fprintf(fout, "U  1\n");
+       gbfprintf(fout, "G  WGS 84\n");
+       gbfprintf(fout, "U  1\n");
        
        /* process options */
        
diff --git a/cst.c b/cst.c
index 8528d3b5ad14a64e8da6832f597fe717b4914def..a42f4ffddf07fb870419a5d5858b7fb80e7d41ec 100644 (file)
--- a/cst.c
+++ b/cst.c
@@ -38,8 +38,7 @@
 #define CST_REFERENCE  4
 #define CST_VERSION    5
 
-static FILE *fin;
-static char *fin_name;
+static gbfile *fin;
 
 static route_head *temp_route;
 
@@ -139,17 +138,14 @@ cst_make_url(char *str)
 static void
 cst_rd_init(const char *fname)
 {
-       fin_name = xstrdup(fname);
-       fin = xfopen(fname, "rb", MYNAME);
-       
+       fin = gbfopen(fname, "rb", MYNAME);
        temp_route = NULL;
 }
 
 static void
 cst_rd_deinit(void)
 {
-       fclose(fin);
-       xfree(fin_name);
+       gbfclose(fin);
 }
 
 /* --------------------------------------------------------------------------- */
@@ -167,11 +163,8 @@ cst_data_read(void)
        int cst_points = -1;
        route_head *track = NULL;
        waypoint *wpt = NULL;
-       textfile_t *tin;
-       
-       tin = textfile_init(fin);
        
-       while ((buff = textfile_read(tin)))
+       while ((buff = gbfgetstr(fin)))
        {
                char *cin = buff;
                
@@ -216,14 +209,14 @@ cst_data_read(void)
                                                        wpt->url = cst_make_url(cin);
                                        }
                                        
-                                       while ((buff = textfile_read(tin)))
+                                       while ((buff = gbfgetstr(fin)))
                                        {
                                                line++;
                                                cin = lrtrim(buff);
                                                
                                                if (strcmp(cin + 2, "note") == 0)
                                                {
-                                                       buff = textfile_read(tin);
+                                                       buff = gbfgetstr(fin);
                                                        if (buff == NULL) buff = "";
                                                        line++;
                                                        cin = lrtrim(buff);
@@ -318,23 +311,19 @@ cst_data_read(void)
        
        if ((cst_points >= 0) && (data_lines != cst_points))
                warning(MYNAME ": Loaded %d point(s), but line %d says %d!\n", data_lines, line_of_count, cst_points);
-       
-       textfile_done(tin);
 }
 
 #if 0
 static void
 cst_wr_init(const char *fname)
 {
-       fout_name = xstrdup(fname);
-       fout = xfopen(fname, "w", MYNAME);
+       fout = gbfopen(fname, "w", MYNAME);
 }
 
 static void
 cst_wr_deinit(void)
 {
-       fclose(fout);
-       xfree(fout_name);
+       gbfclose(fout);
 }
 
 static void 
index 8d58cf33316dba04f443ad01d469e53e44b09689..442db7a3ad0c5acf90f21786ad3cb807bb627b18 100644 (file)
@@ -48,7 +48,7 @@ typedef struct gtxt_flags_s {
        unsigned int track_header_written:1;
 } gtxt_flags_t;
 
-static FILE *fin, *fout;
+static gbfile *fin, *fout;
 static route_head *current_trk, *current_rte;
 static int waypoints;
 static int routepoints;
@@ -327,7 +327,7 @@ print_position(const waypoint *wpt)
                deg++;
                min = 0;
        }
-       fprintf(fout, "%c%d %0*.*f ", lat < 0.0 ? 'S' : 'N', deg, precision + 3, precision, min);
+       gbfprintf(fout, "%c%d %0*.*f ", lat < 0.0 ? 'S' : 'N', deg, precision + 3, precision, min);
        
        deg = fabs(lon);
        min = (double)60.0 * (fabs(lon) - deg);
@@ -336,7 +336,7 @@ print_position(const waypoint *wpt)
                deg++;
                min = 0;
        }
-       fprintf(fout, "%c%d %0*.*f\t", lon < 0.0 ? 'W' : 'E', deg, precision + 3,  precision, min);
+       gbfprintf(fout, "%c%d %0*.*f\t", lon < 0.0 ? 'W' : 'E', deg, precision + 3,  precision, min);
 }
 
 static void
@@ -348,7 +348,7 @@ print_date_and_time(const time_t time, const int time_only)
        if (time_only) {
                tm = *gmtime(&time);
                snprintf(tbuf, sizeof(tbuf), "%d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
-               fprintf(fout, "%s", tbuf);
+               gbfprintf(fout, "%s", tbuf);
        }
        else if (time != 0) {
                if (gtxt_flags.utc) {
@@ -358,9 +358,9 @@ print_date_and_time(const time_t time, const int time_only)
                else
                        tm = *localtime(&time);
                strftime(tbuf, sizeof(tbuf), date_time_format, &tm);
-               fprintf(fout, "%s ", tbuf);
+               gbfprintf(fout, "%s ", tbuf);
        }
-       fprintf(fout, "\t");
+       gbfprintf(fout, "\t");
 }
 
 static void
@@ -381,12 +381,12 @@ print_categories(gbuint16 categories)
                        }
                        else c = NULL;
                                
-                       fprintf(fout, "%s", (count++ > 0) ? "," : "");
+                       gbfprintf(fout, "%s", (count++ > 0) ? "," : "");
                        if (c == NULL)
-                               fprintf(fout, "Category %d", i+1);
-//                             fprintf(fout, "%s", gps_categories[i]);
+                               gbfprintf(fout, "Category %d", i+1);
+//                             gbfprintf(fout, "%s", gps_categories[i]);
                        else
-                               fprintf(fout, "%s", c);
+                               gbfprintf(fout, "%s", c);
                        
                }
                categories = categories >> 1;
@@ -402,7 +402,7 @@ print_course(const waypoint *A, const waypoint *B)          /* seems to be okay */
                if (course >= 360) {
                        course -= 360;
                }
-               cet_fprintf(fout, &cet_cs_vec_cp1252, "%d%c true", course, 0xB0);
+               cet_gbfprintf(fout, &cet_cs_vec_cp1252, "%d%c true", course, 0xB0);
        }
 }
 
@@ -415,28 +415,28 @@ print_distance(const double distance, const int no_scale, const int with_tab)
                dist = METERS_TO_FEET(dist);
        
                if ((dist < 5280) || no_scale)
-                       fprintf(fout, "%.f ft", dist);
+                       gbfprintf(fout, "%.f ft", dist);
                else {
                        dist = METERS_TO_MILES(distance);
                        if (dist < (double)100)
-                               fprintf(fout, "%.1f mi", dist);
+                               gbfprintf(fout, "%.1f mi", dist);
                        else
-                               fprintf(fout, "%d mi", si_round(dist));
+                               gbfprintf(fout, "%d mi", si_round(dist));
                }
        }
        else
        {
                if ((dist < 1000) || no_scale)
-                       fprintf(fout, "%.f m", dist);
+                       gbfprintf(fout, "%.f m", dist);
                else {
                        dist = dist / (double)1000.0;
                        if (dist < (double)100)
-                               fprintf(fout, "%.1f km", dist);
+                               gbfprintf(fout, "%.1f km", dist);
                        else
-                               fprintf(fout, "%d km", si_round(dist));
+                               gbfprintf(fout, "%d km", si_round(dist));
                }
        }
-       if (with_tab) fprintf(fout, "\t");
+       if (with_tab) gbfprintf(fout, "\t");
 }
 
 static void
@@ -458,15 +458,15 @@ print_speed(double *distance, time_t *time)
                int ispeed = si_round(speed);
                
                if (speed < (double)0.01)
-                       fprintf(fout, "0 %s", unit);
+                       gbfprintf(fout, "0 %s", unit);
                else if (ispeed < 2)
-                       fprintf(fout, "%.1f %s", speed, unit);
+                       gbfprintf(fout, "%.1f %s", speed, unit);
                else
-                       fprintf(fout, "%d %s", ispeed, unit);
+                       gbfprintf(fout, "%d %s", ispeed, unit);
        }
        else
-               fprintf(fout, "0 %s", unit);
-       fprintf(fout, "\t");
+               gbfprintf(fout, "0 %s", unit);
+       gbfprintf(fout, "\t");
 }
 
 static void
@@ -482,7 +482,7 @@ print_string(const char *fmt, const char *string)
                        *c = ' ';
                }
        }
-       fprintf(fout, fmt, buff);
+       gbfprintf(fout, fmt, buff);
        xfree(buff);
 }
 
@@ -513,7 +513,7 @@ write_waypt(const waypoint *wpt)
        else
                wpt_type = gt_waypt_class_names[0];
        
-       fprintf(fout, "Waypoint\t%s\t", (wpt->shortname) ? wpt->shortname : "");
+       gbfprintf(fout, "Waypoint\t%s\t", (wpt->shortname) ? wpt->shortname : "");
        if (wpt_class <= gt_waypt_class_airport_ndb) {
                char *temp = wpt->notes;
                if (temp == NULL) {
@@ -525,35 +525,35 @@ write_waypt(const waypoint *wpt)
                print_string("%s\t", temp);
        }
        else
-               fprintf(fout, "\t");
-       fprintf(fout, "%s\t", wpt_type);
+               gbfprintf(fout, "\t");
+       gbfprintf(fout, "%s\t", wpt_type);
                
        print_position(wpt);
        
        if IS_VALID_ALT(wpt->altitude)
                print_distance(wpt->altitude, 1, 0);
-       fprintf(fout, "\t");
+       gbfprintf(fout, "\t");
        
        x = GMSD_GET(depth, unknown_alt);
        if (x != unknown_alt)
                print_distance(x, 1, 0);
-       fprintf(fout, "\t");
+       gbfprintf(fout, "\t");
 
        x = GMSD_GET(proximity, unknown_alt);
        if (x != unknown_alt)
                print_distance(x, 0, 0);
-       fprintf(fout, "\t");
+       gbfprintf(fout, "\t");
        
        x = GMSD_GET(temperature, unknown_alt);
        if (x != unknown_alt) {
                if (gtxt_flags.celsius)
-                       fprintf(fout, "%.f C", x);
+                       gbfprintf(fout, "%.f C", x);
                else
-                       fprintf(fout, "%.f F", (x * 1.8) + 32);
+                       gbfprintf(fout, "%.f F", (x * 1.8) + 32);
        }
-       fprintf(fout, "\t%s\t", dspl_mode);
+       gbfprintf(fout, "\t%s\t", dspl_mode);
        
-       fprintf(fout, "Unknown\t");                             /* Color is fixed: Unknown */
+       gbfprintf(fout, "Unknown\t");                           /* Color is fixed: Unknown */
 
        icon = GMSD_GET(icon, -1);
        if (icon == -1) {
@@ -572,7 +572,7 @@ write_waypt(const waypoint *wpt)
        print_string("%s\t", wpt->url ? wpt->url : ""); 
        print_categories(GMSD_GET(category, 0));
        
-       fprintf(fout, "\r\n");
+       gbfprintf(fout, "\r\n");
 }
 
 static void
@@ -586,15 +586,15 @@ route_disp_hdr_cb(const route_head *rte)
 
        if (!gtxt_flags.route_header_written) {
                gtxt_flags.route_header_written = 1;
-               fprintf(fout, "\r\n\r\nHeader\t%s\r\n", headers[route_header]);
+               gbfprintf(fout, "\r\n\r\nHeader\t%s\r\n", headers[route_header]);
        }
 
        print_string("\r\nRoute\t%s\t", current_trk->rte_name ? current_trk->rte_name : "");
        print_distance(cur_info->length, 0, 1);
        print_course(cur_info->first_wpt, cur_info->last_wpt);
-       fprintf(fout, "\t%d waypoints\t", cur_info->count);
+       gbfprintf(fout, "\t%d waypoints\t", cur_info->count);
        print_string("%s\r\n", rte->rte_url ? rte->rte_url : "");
-       fprintf(fout, "\r\nHeader\t%s\r\n\r\n", headers[rtept_header]);
+       gbfprintf(fout, "\r\nHeader\t%s\r\n\r\n", headers[rtept_header]);
 }
 
 static void
@@ -608,8 +608,8 @@ route_disp_wpt_cb(const waypoint *wpt)
 {
        waypoint *prev = cur_info->prev_wpt;
        
-       fprintf(fout, "Route Waypoint\t");
-       fprintf(fout, "%s\t", wpt->shortname);
+       gbfprintf(fout, "Route Waypoint\t");
+       gbfprintf(fout, "%s\t", wpt->shortname);
 
        if (prev != NULL)
        {
@@ -622,7 +622,7 @@ route_disp_wpt_cb(const waypoint *wpt)
        else 
                print_distance(0, 1, 0);        
 
-       fprintf(fout, "\r\n");
+       gbfprintf(fout, "\r\n");
        
        cur_info->prev_wpt = (waypoint *)wpt;
 }
@@ -638,7 +638,7 @@ track_disp_hdr_cb(const route_head *track)
        
        if (!gtxt_flags.track_header_written) {
                gtxt_flags.track_header_written = 1;
-               fprintf(fout, "\r\n\r\nHeader\t%s\r\n", headers[track_header]);
+               gbfprintf(fout, "\r\n\r\nHeader\t%s\r\n", headers[track_header]);
        }
                
        print_string("\r\nTrack\t%s\t", current_trk->rte_name ? current_trk->rte_name : "");
@@ -647,7 +647,7 @@ track_disp_hdr_cb(const route_head *track)
        print_distance(cur_info->length, 0, 1);
        print_speed(&cur_info->length, &cur_info->time);
        print_string("%s", (track->rte_url != NULL) ? track->rte_url : "");
-       fprintf(fout, "\r\n\r\nHeader\t%s\r\n\r\n", headers[trkpt_header]);
+       gbfprintf(fout, "\r\n\r\nHeader\t%s\r\n\r\n", headers[trkpt_header]);
 }
 
 static void
@@ -663,15 +663,15 @@ track_disp_wpt_cb(const waypoint *wpt)
        time_t delta;
        double dist;
        
-       fprintf(fout, "Trackpoint\t");
+       gbfprintf(fout, "Trackpoint\t");
 
        print_position(wpt);
        print_date_and_time(wpt->creation_time, 0);
        if IS_VALID_ALT(wpt->altitude)
                print_distance(wpt->altitude, 1, 0);
-       fprintf(fout, "\t0.0 %s", (gtxt_flags.metric) ? "m" : "ft");
+       gbfprintf(fout, "\t0.0 %s", (gtxt_flags.metric) ? "m" : "ft");
        if (prev != NULL) {
-               fprintf(fout, "\t");
+               gbfprintf(fout, "\t");
                delta = wpt->creation_time - prev->creation_time;
                dist = distance(prev->latitude, prev->longitude, wpt->latitude, wpt->longitude);
                print_distance(dist, 0, 1);
@@ -679,7 +679,7 @@ track_disp_wpt_cb(const waypoint *wpt)
                print_speed(&dist, &delta);
                print_course(prev, wpt);
        }
-       fprintf(fout, "\r\n");
+       gbfprintf(fout, "\r\n");
        
        cur_info->prev_wpt = (waypoint *)wpt;
 }
@@ -693,7 +693,7 @@ garmin_txt_wr_init(const char *fname)
 {
        memset(&gtxt_flags, 0, sizeof(gtxt_flags));
        
-       fout = xfopen(fname, "wb", MYNAME);
+       fout = gbfopen(fname, "wb", MYNAME);
        grid_index = 1;
        
        gtxt_flags.metric = (toupper(*get_option_val(opt_dist, "m")) == 'M');
@@ -720,15 +720,15 @@ garmin_txt_wr_init(const char *fname)
 static void
 garmin_txt_wr_deinit(void)
 {
-       fclose(fout);
+       gbfclose(fout);
        xfree(date_time_format);
 }
 
 static void
 garmin_txt_write(void)
 {
-       cet_fprintf(fout, &cet_cs_vec_cp1252, "Grid\tLat/Lon hddd%cmm.mmm'\r\n", 0xB0);
-       fprintf(fout, "Datum\t%s\r\n\r\n", datum_str);
+       cet_gbfprintf(fout, &cet_cs_vec_cp1252, "Grid\tLat/Lon hddd%cmm.mmm'\r\n", 0xB0);
+       gbfprintf(fout, "Datum\t%s\r\n\r\n", datum_str);
 
        waypoints = 0;
        gtxt_flags.enum_waypoints = 1;                  /* enum all waypoints */
@@ -745,7 +745,7 @@ garmin_txt_write(void)
                route_disp_all(NULL, NULL, enum_waypt_cb);
                qsort(wpt_a, waypoints, sizeof(*wpt_a), sort_waypt_cb);
                
-               fprintf(fout, "Header\t%s\r\n\r\n", headers[waypt_header]);
+               gbfprintf(fout, "Header\t%s\r\n\r\n", headers[waypt_header]);
                for (i = 0; i < waypoints; i++)
                {
                        waypoint *wpt = wpt_a[i];
@@ -1200,7 +1200,7 @@ garmin_rd_init(const char *fname)
 {
        memset(&gtxt_flags, 0, sizeof(gtxt_flags));
        
-       fin = xfopen(fname, "rb", MYNAME);
+       fin = gbfopen(fname, "rb", MYNAME);
        memset(&header_ct, 0, sizeof(header_ct));
 
        datum_index = -1;
@@ -1217,7 +1217,7 @@ garmin_rd_deinit(void)
        for (h = waypt_header; h <= unknown_header; h++) {
                free_header(h);
        }
-       fclose(fin);
+       gbfclose(fin);
        xfree(date_time_format);
 }
 
@@ -1225,12 +1225,10 @@ static void
 garmin_txt_read(void)
 {
        char *buff;
-       textfile_t *tin;
 
        current_line = 0;
-       tin = textfile_init(fin);
 
-       while ((buff = textfile_read(tin))) {
+       while ((buff = gbfgetstr(fin))) {
                char *cin;
                
                current_line++;
@@ -1255,7 +1253,6 @@ garmin_txt_read(void)
                /* flush pending data */
                while (csv_lineparse(NULL, "\t", "", 0));
        }
-       textfile_done(tin);
 }
 
 ff_vecs_t garmin_txt_vecs = {
index 0b0ee5fc19af9236c7efea81681556d1ea4610fb..8237bdee137e390aff27cca0321e1f6c7fa55d91 100644 (file)
--- a/stmwpp.c
+++ b/stmwpp.c
@@ -26,8 +26,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-static FILE *fin;
-static FILE *fout;
+static gbfile *fin, *fout;
 static route_head *track, *route;
 static waypoint *wpt;
 
@@ -56,7 +55,7 @@ arglist_t stmwpp_args[] =
 static void
 stmwpp_rd_init(const char *fname)
 {
-       fin = xfopen(fname, "rb", MYNAME);
+       fin = gbfopen(fname, "rb", MYNAME);
        track = NULL;
        route = NULL;
        wpt = NULL;
@@ -65,25 +64,22 @@ stmwpp_rd_init(const char *fname)
 static void
 stmwpp_rd_deinit(void)
 {
-       fclose(fin);
+       gbfclose(fin);
 }
 
 static void
 stmwpp_data_read(void)
 {
        char *buff;
-       textfile_t *tin;
-       
-       tin = textfile_init(fin);
        
        what = STM_NOTHING;
-       buff = textfile_read(tin);
+       buff = gbfgetstr(fin);
        buff = (buff == NULL) ? "" : buff;
        
        if (strncmp(buff, "Datum,WGS 84,WGS 84,", 20) != 0)
                fatal(MYNAME ": Invalid GPS datum or not \"WaypointPlus\"\" file!\n");
        
-       while ((buff = textfile_read(tin)))
+       while ((buff = gbfgetstr(fin)))
        {
                char *c;
                int column = -1;
@@ -181,19 +177,18 @@ stmwpp_data_read(void)
                        wpt = NULL;
                }
        }
-       textfile_done(tin);
 }
 
 static void
 stmwpp_rw_init(const char *fname)
 {
-       fout = xfopen(fname, "wb", MYNAME);
+       fout = gbfopen(fname, "wb", MYNAME);
 }
 
 static void
 stmwpp_rw_deinit(void)
 {
-       fclose(fout);
+       gbfclose(fout);
 }
 
 static void
@@ -216,7 +211,7 @@ stmwpp_write_double(const double val)
        c = buff + snprintf(buff, sizeof(buff), "%3.7f", val);
        while (*--c == '0') *c = '\0';
        if (*c == '.') *c = '0';
-       fprintf(fout, "%s,", buff);
+       gbfprintf(fout, "%s,", buff);
 }
 
 static void
@@ -238,27 +233,27 @@ stmwpp_waypt_cb(const waypoint *wpt)
        {
                case STM_WAYPT:
                case STM_RTEPT:
-                       fprintf(fout, "WP,D,%s,", wpt->shortname);
+                       gbfprintf(fout, "WP,D,%s,", wpt->shortname);
                        break;
                        
                case STM_TRKPT:
-                       fprintf(fout, "TP,D,");
+                       gbfprintf(fout, "TP,D,");
                        break;
        }
        stmwpp_write_double(wpt->latitude);
        stmwpp_write_double(wpt->longitude);
-       fprintf(fout, "%s,%s", cdate, ctime);
+       gbfprintf(fout, "%s,%s", cdate, ctime);
        switch(what)
        {
                case STM_WAYPT:
                case STM_RTEPT:
-                       fprintf(fout, ".%02d", wpt->centiseconds);
+                       gbfprintf(fout, ".%02d", wpt->centiseconds);
                        break;
                case STM_TRKPT:
-                       fprintf(fout, ".%03d", wpt->centiseconds * 10);
+                       gbfprintf(fout, ".%03d", wpt->centiseconds * 10);
                        break;
        }
-       fprintf(fout, ",\r\n");
+       gbfprintf(fout, ",\r\n");
 }
 
 static void
@@ -270,7 +265,7 @@ stmwpp_data_write(void)
        else
                track_index = 1;
                
-       fprintf(fout, "Datum,WGS 84,WGS 84,0,0,0,0,0\r\n");
+       gbfprintf(fout, "Datum,WGS 84,WGS 84,0,0,0,0,0\r\n");
        
        switch(global_opts.objective)
        {